package com.why.connector.factory;

import com.why.configurebean.DefaultConfiguration;
import com.why.connector.session.DefaultSqlSession;
import com.why.connector.session.SqlSession;
import com.why.executor.DefaultExecutor;
import com.why.executor.Executor;

public class DefualtSqlSessionFactory implements SqlSessionFactory {
    private DefaultConfiguration configuration;


    public DefualtSqlSessionFactory(DefaultConfiguration configuration) {
        this.configuration = configuration;
    }


    @Override
    public DefaultConfiguration getConfiguration() {
        return configuration;
    }

    @Override
    public SqlSession openSqlSession() {
        Executor executor = new DefaultExecutor(configuration.getProperties());
        SqlSession sqlSession = new DefaultSqlSession(configuration, executor);
        return sqlSession;
    }
}
